package com.gitee.target123.develop.mysql;

import com.gitee.target123.develop.mysql.aop.InsertRedisLockAop;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

@Configuration
public class MysqlAutoConfiguration {

    @ConditionalOnClass(value = {Aspect.class,StringRedisTemplate.class})
    @AutoConfigureAfter(RedisAutoConfiguration.class)
    static class RedisConfig{
        @Bean
        @ConditionalOnMissingBean
        public InsertRedisLockAop insertRedisLockAop(StringRedisTemplate stringRedisTemplate){
            return new InsertRedisLockAop(stringRedisTemplate);
        }
    }
}
